<?php
require_once('rss_fetch.inc');
//$url = "http://demo.ublip.com/readings/last/1";
$url="http://earthquake.usgs.gov/earthquakes/shakemap/rss.xml";
$rss = fetch_rss($url);
mysql_connect('localhost', 'root', '') OR die(fail('Could not connect to database.'));
mysql_select_db('catnat');
echo "<strong>" . $rss->channel['title'] . "</strong><br />";
foreach ($rss->items as $item) {
	$title 			= $item['title'];
	$description 	= $item['description'];
	//$pubDate 		= $item['pubDate'];
	$link 			= $item['link'];
	$lat 			= $item['geo']['lat'];
	$lon 			= $item['geo']['long'];
	$subject		= $item['dc']['subject'];
	$seconds		= $item['eq']['seconds'];
	$depth 			= $item['eq']['depth'];
	echo($title . "<br />");
	echo($description . "<br />");
	//echo($pubDate . "<br />");
	echo($link. "<br />");
	echo($lat. "<br />");
	echo($lon. "<br />");
	echo($subject. "<br />");
	echo($seconds. "<br />");
	echo($depth. "<br />");
	
	//$query = mysql_query("CALL insert_earthquake('title','description','jeudi 12 juillet 2012 20:13','link','lat','lon')"); 
	$query = mysql_query("CALL insert_earthquake('".$title."','".$description."','jeudi 12 juillet 2012 20:13','".$link."','".$lat."','".$lon."')"); 
}
?>